'''
@project : gops
@author  : lupuxiao
@contact : jiucows@gmail.com
@file    : views.py
@time    : 2021-01-28 11:21:19
'''

from django.shortcuts import render, redirect

# Create your views here.
from django.urls import reverse_lazy
from django.views.generic.list import ListView
from django.views.generic import View
from django.contrib.auth import authenticate
from django.contrib.auth import login as auth_login
from django.http import HttpResponse,HttpResponseRedirect
from django.shortcuts import render
class LoginView(View):
    def get(self,request):
        user = request.user
        print(user)
        if user.is_authenticated:
            auth_login(request, user,backend='django_cas_ng.backends.CASBackend')
            return redirect('index')

        return  render(request,"login.html")

    def post(self,request):
        data = request.POST

        authcode = data.get("authcode")
        username = data.get("username")
        password = data.get("password")

        print(authcode,username,password)
        return  render(request,"index.html")

class IndexView(View):
    def get(self,request):
        print(request.user)

        return render(request, "index.html")

class TestA(View):
    def get(self,request):
        print(request.user)
        return render(request, "test.html")